/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * Portions created by the Initial Developer are
 * Copyright (C) 2012 the Initial Developer.
 * All Rights Reserved.
 *
 * The Original Code is "http://semi-frame.googlecode.com/svn/trenk/".
 *
 * The Initial Developer of the Original Code is the author below.
 */
/**
 * @file SharedRecord.h
 * @brief Application scope contexts.
 * @author mornongcloud
 * @date 2011/12/21
 */

#ifndef SEMISHAREDRECORD_H_
#define SEMISHAREDRECORD_H_

#include "semi/SharedContext.h"

namespace semi {

/**
 * @brief Record contexts.
 *
 * @date 2011/12/21
 */
class SharedRecord: public semi::SharedContext {
public:
	SharedRecord(std::string filename, int recSize, int recCount = 1,
			bool lock = true);
	virtual ~SharedRecord();

	void read(void * ret, int index = -1, int count = 1, bool lock = false);
	void get(void * ret, int index = -1, int count = 1);
	void set(void * st, int index = -1, int count = 1);

	int recSize;
	int recCount;
	int index;

	//private:
	// void * read(int index, int count, bool lock); // no lock
};

}

#endif /* SEMISHAREDRECORD_H_ */
